package cn.sofwin.boot.crud.web;

import cn.sofwin.core.support.api.StatusCode;
import cn.sofwin.core.support.bean.db.PageParams;
import cn.sofwin.core.support.bean.db.Selector;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import cn.sofwin.core.mvc.annotation.BaseService;
import cn.sofwin.core.mvc.web.BaseController;
import cn.sofwin.boot.crud.entity.BaArtical;
import cn.sofwin.boot.crud.service.BaArticalService;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;

/**
 * 控制器
 * @author LetCode
 * @since 1.0
 *
 */
@RestController
@RequestMapping(value = "/api/baArtical")
public class BaArticalController extends BaseController<BaArtical> {

	@BaseService
    @Autowired
	BaArticalService baArticalService;

	@Override
	protected void beforeList(Selector selector, PageParams pageParams, HttpServletRequest request) {
		selector.notEq("status",-1);
		super.beforeList(selector, pageParams, request);
	}

	@Override
	protected StatusCode beforeCreate(BaArtical entity, HttpServletRequest request) {
		entity.setAddTime(new Date());
		return super.beforeCreate(entity, request);
	}
}